/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package sv.com.bolsaTrabajo.model.dao;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import sv.com.bolsaTrabajo.model.entities.Departamento;
import sv.com.bolsaTrabajo.model.entities.Municipio;
import sv.com.bolsaTrabajo.model.entities.Pais;

/**
 *
 * @author sysmanager
 */
@Stateless
public class DepartamentoFacade extends AbstractFacade<Departamento> {
    @PersistenceContext(unitName = "BolsaTrabajoPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public DepartamentoFacade() {
        super(Departamento.class);
    }

    public List<Municipio> obtenerTodosDepartamentoPorPais(Pais id_pais) {
        Query q = getEntityManager().createQuery("select d from Departamento d where d.id_pais = :idPais");
        q.setParameter("Pais", id_pais);
        return q.getResultList();
    }
    
}
